---
description: "Reference for Nitric's v0 JVM library - Returns a reference to a known version of a secret."
---

# JVM - secret.version()

Returns a reference to a known version of a secret.

<Tabs syncKey="jvm-lang">

<TabItem label="Java">

```java
import io.nitric.Nitric;
import io.nitric.resources.SecretPermission;

public class Application {
  public static void main(String[] args) {
    var secrets = Nitric.INSTANCE.secret("encryptionKey").with(SecretPermission.Access);

    var keyVersion = secrets.version("the-version-id");

    Nitric.INSTANCE.run();
  }
}
```

</TabItem>

<TabItem label="Kotlin">

```kotlin
import io.nitric.Nitric
import io.nitric.resources.SecretPermission

fun main() {
  val secrets = Nitric.secret("encryptionKey").with(SecretPermission.Access)

  val keyVersion = secrets.version("the-version-id")

  Nitric.run()
}
```

</TabItem>

</Tabs>

## Parameters

<Properties>
  <Property name="version" required type="String">
    The version ID. This value is returned from [secret.put()](./secret-put).
  </Property>
</Properties>

## Examples

### Return a reference to a known secret version

<Tabs syncKey="jvm-lang">

<TabItem label="Java">

```java
import io.nitric.Nitric;
import io.nitric.resources.SecretPermission;

public class Application {
  public static void main(String[] args) {
    var secrets = Nitric.INSTANCE.secret("encryptionKey").with(SecretPermission.Access);

    var keyVersion = secrets.version("the-version-id");

    Nitric.INSTANCE.run();
  }
}
```

</TabItem>

<TabItem label="Kotlin">

```kotlin
import io.nitric.Nitric
import io.nitric.resources.SecretPermission

fun main() {
  val secrets = Nitric.secret("encryptionKey").with(SecretPermission.Access)

  val keyVersion = secrets.version("the-version-id")

  Nitric.run()
}
```

</TabItem>

</Tabs>

### Access the value of a known secret version

<Tabs syncKey="jvm-lang">

<TabItem label="Java">

```java
import io.nitric.Nitric;
import io.nitric.resources.SecretPermission;

public class Application {
  public static void main(String[] args) {
    var secrets = Nitric.INSTANCE.secret("encryptionKey").with(SecretPermission.Access);

    var contents = secrets.version("the-version-id").access();

    System.out.println(contents.toString());

    Nitric.INSTANCE.run();
  }
}
```

</TabItem>

<TabItem label="Kotlin">

```kotlin
import io.nitric.Nitric
import io.nitric.resources.SecretPermission

fun main() {
  val secrets = Nitric.secret("encryptionKey").with(SecretPermission.Access)

  val contents = secrets.version("the-version-id").access()

  println(contents.toString())

  Nitric.run()
}
```

</TabItem>

</Tabs>

### See also

- [secret.version().access()](./secret-version-access)
